package com.example.nettyudp.config;

import com.example.nettyudp.server.NettyBean;
import com.example.nettyudp.server.NettyServer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.net.InetSocketAddress;

/**
 * @author FDJ,
 * @date 2020/5/26,
 * @time 13:47
 */
@Configuration
public class NettyConfig {

    @Value("${netty.from.ip}")
    private String ip;

    @Value("${netty.from.port}")
    private int port;

    @Bean
    public NettyBean getNettyBean() {
        return new NettyBean();
    }


    @Bean
    public NettyServer getNettyServer() {
        NettyServer nettyServer = new NettyServer();
        nettyServer.start(new InetSocketAddress(ip, port));
        return nettyServer;
    }
}
